home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 14 / CU Amiga Magazine's Super CD-ROM 14 (1997)(EMAP Images)(GB)(Track 1 of 3)[!][issue 1997-09].iso / CUCD / Programming / Mesa-2.2 / include / GL / Amigamesa.h next >
Encoding:
C/C++ Source or Header  |  1997-06-25  |  11.6 KB  |  342 lines

  1. /* Amigamesa.h */
  2.  
  3. /*
  4.  * Mesa 3-D graphics library
  5.  * Version:  1.2
  6.  * Copyright (C) 1995  Brian Paul  (brianp@ssec.wisc.edu)
  7.  *
  8.  * This library is free software; you can redistribute it and/or
  9.  * modify it under the terms of the GNU Library General Public
  10.  * License as published by the Free Software Foundation; either
  11.  * version 2 of the License, or (at your option) any later version.
  12.  *
  13.  * This library is distributed in the hope that it will be useful,
  14.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16.  * Library General Public License for more details.
  17.  *
  18.  * You should have received a copy of the GNU Library General Public
  19.  * License along with this library; if not, write to the Free
  20.  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21.  */
  22.  
  23.  
  24. /*
  25. Implementions of new drawing rutines:
  26.  
  27. you implement a own init for your rutines/hardware
  28. and make some test and calls it from AmigaMesaCreateContext()
  29. (look in the file src/amigamesa.c I'll thing you get it)
  30. Be sure to fill this three ponters out:
  31.     void (*InitDD)( void );                                 // keep track of witch drawing rutines should be used
  32.     void (*Dispose) (struct amigamesa_context *c);  // Use this when AmigaMesaDestroyContext is called 
  33.     void (*SwapBuffer) (void);                              // Use this when AmigaMesaSwapBuffers is called 
  34. where InitDD sets the DD structure in orginal mesa with pointers to drawing rutines
  35. Dispose is called when someone quits/closes down your made inits
  36. SwapBuffer is called when one is changing buffer in dubble buffering mode
  37.  
  38. Write nice drawing rutines like those in src/amigamesa.c on make sure
  39. that it's those you set in your InitDD rutine.
  40.  
  41. Add enum for your drawingmode for the taglist and if you need more tags also implement them
  42. If posible some autodetection code in AmigaMesaCreateContext
  43. Add enums and error codes if you neads 
  44.  
  45. PUT ALL YOUR NEADED DATA IN amigamesa_context->(void *)data in for your gfx driver
  46. private structure.
  47.  
  48. Send the code to me and I will include it in the main code.
  49. */
  50.  
  51. /*
  52. $Id: Amigamesa.h 1.5 1997/06/25 19:16:45 StefanZ Exp StefanZ $
  53.  
  54. $Log: Amigamesa.h $
  55.  * Revision 1.5  1997/06/25  19:16:45  StefanZ
  56.  * *** empty log message ***
  57.  *
  58.  * Revision 1.3  1996/10/06  20:35:11  StefanZ
  59.  * Source bump before Mesa 2.0
  60.  *
  61.  * Revision 1.2  1996/08/14  22:16:31  StefanZ
  62.  * New Api to amigaspecific functions, Added suport for gfx-cards
  63.  *
  64.  * Revision 1.1  1996/06/02  00:15:03   StefanZ
  65.  * Initial revision
  66.  *
  67.  * Revision 1.0  1996/02/21  11:09:45   brianp
  68.  * A copy of amesa.h version 1.4 in a brave atempt to make a amiga interface
  69.  *
  70.  */
  71.  
  72.  
  73. /* Example usage:
  74.  
  75. 1. Make a window using Intuition calls
  76.  
  77. 2. Call AMesaCreateContext() to make a rendering context and attach it
  78.     to the window made in step 1.
  79.  
  80. 3. Call AMesaMakeCurrent() to make the context the active one.
  81.  
  82. 4. Make gl* calls to render your graphics.
  83.  
  84. 5. When exiting, call AMesaDestroyContext().
  85.  
  86. */
  87.  
  88.  
  89.  
  90. #ifndef AMIGAMESA_H
  91. #define AMIGAMESA_H
  92.  
  93. #ifdef __cplusplus
  94. extern "C" {
  95. #endif
  96.  
  97.  
  98. #include <intuition/intuition.h>
  99. #include "GL/gl.h"
  100. #ifdef __GNUC__
  101. #include "../../src/context.h"
  102. #include "../../src/types.h"
  103. #else
  104. #include "//src/context.h"
  105. #include "//src/types.h"
  106. #endif
  107.  
  108. #ifndef UTILITY_TAGITEM_H
  109. #include <utility/tagitem.h>
  110. #endif
  111.  
  112.  
  113. /*      Drawmode to use         */
  114.  
  115. #define ADISP_CYBERGFX
  116. #define ADISP_AGA
  117.  
  118.  
  119. enum AMesaError {AMESA_OUT_OF_MEM,AMESA_RASTPORT_TAG_MISSING,AMESA_SCREEN_TAG_MISSING,AMESA_WINDOW_TAG_MISSING};
  120.  
  121.  
  122. struct amigamesa_visual
  123. {
  124.    GLvisual  *gl_visual;
  125.    GLboolean db_flag;       /* double buffered? */
  126.    GLboolean rgb_flag;      /* RGB mode? */
  127.    GLboolean alpha_flag;   /* Alphacolor? */
  128.    GLuint    depth;             /* bits per pixel (1, 8, 24, etc) */
  129. };
  130.  
  131.  
  132.  
  133. struct amigamesa_buffer
  134. {
  135.    GLframebuffer *gl_buffer;    /* The depth, stencil, accum, etc buffers */
  136.    /* your window handle, etc */
  137. };
  138.  
  139.  
  140. /*
  141.  * This is the Amiga/Mesa context structure.  This usually contains
  142.  * info about what window/buffer we're rendering too, the current
  143.  * drawing color, etc.
  144.  */
  145. /*
  146.     GLboolean db_flag;                 */ /* double buffered? *//*
  147.     GLboolean rgb_flag;                */ /* RGB mode? *//*
  148. */
  149.  
  150.  
  151. struct amigamesa_context
  152. {
  153.    GLcontext            *gl_ctx;    /* the core library context */
  154.     struct amigamesa_visual  *visual; /* the visual context */
  155.    struct amigamesa_buffer  *buffer; /* the buffer context */
  156.  
  157.     struct amigamesa_context *share;
  158.  
  159.     unsigned long flags;            /*0x1 = own visuel 0x2 = own buffer */
  160.  
  161.     void * data;                    /* Put your special GFX-driver data here */
  162.  
  163.  
  164.     unsigned long pixel;            /* current color index or RGBA pixel value */
  165.     unsigned long clearpixel;   /* pixel for clearing the color buffers */
  166.  
  167.     /* etc... */
  168.     struct Window *window;          /* Not neaded if in dubbelbuff needed */        /* the Intuition window */
  169.     struct RastPort *front_rp;  /* front rastport */
  170.     struct RastPort *back_rp;       /* back rastport (NULL if SB or RGB) */
  171.     UBYTE* BackArray;                   /*a pen Array big as drawing area for use in dubelbuff mode*/
  172.     struct RastPort *rp;            /* current rastport */
  173.     struct Screen *Screen;          /* current screen*/
  174.     struct TmpRas *tmpras;          /* tmpras rastport */
  175.     struct RastPort *temprp;
  176.  
  177.     GLuint depth;                       /* bits per pixel (1, 8, 24, etc) */
  178.  
  179.     GLuint  width, height;              /* drawable area */
  180.     GLint       left, bottom;               /* offsets due to window border */
  181.     GLint       RealWidth,RealHeight;   /* the drawingareas real size*/
  182.     GLint       FixedWidth,FixedHeight; /* The internal buffer real size speeds up the drawing a bit*/
  183.  
  184.     unsigned long penconv[256];                 /* when allocating index 13 with a color penconv[13] is the acuat system color */
  185.                                                                 /* penconv[] is changed if auxSetOneColor(index,r,g,b); is called */ 
  186.  
  187.     UBYTE *imageline;                   /* One Line for WritePixelRow renders */
  188.     GLuint *rgb_buffer;                 /*back buffer when in RGBA mode OLD DElete?*/
  189.  
  190.     void (*InitDD)( GLcontext * );                                     /* keep track of witch drawing rutines should be used */
  191.     void (*Dispose) (struct amigamesa_context *c);      /* Use this when AmigaMesaDestroyContext is called */
  192.     void (*SwapBuffer) (struct amigamesa_context *c);   /* Use this when AmigaMesaSwapBuffers is called */
  193. };
  194.  
  195.  
  196.  
  197. typedef struct amigamesa_context *AmigaMesaContext;
  198.  
  199. /**********************************************************************/
  200. /*****                Some Usefull code                                     *****/
  201. /**********************************************************************/
  202.  
  203. /*int RGBA(GLubyte r,GLubyte g,GLubyte b,GLubyte a);*/   /* returns an allocated color thts nearest the wanted one */
  204.  
  205.  
  206. /**********************************************************************/
  207. /*****                  Amiga/Mesa API Functions                            *****/
  208. /**********************************************************************/
  209. struct amigamesa_visual *AmigaMesaCreateVisualTags(long Tag1, ...);
  210. struct amigamesa_context *AmigaMesaCreateContextTags(long Tag1, ...);
  211. void AmigaMesaSetOneColor(struct amigamesa_context *c,int index, float r, float g, float b);
  212. extern GLenum LastError; /* Last Error generated */
  213. #ifdef __GNUC__
  214. struct amigamesa_visual *AmigaMesaCreateVisual(register struct TagItem *tagList);
  215. struct amigamesa_context *AmigaMesaCreateContext(register struct TagItem *tagList );
  216. void AmigaMesaDestroyContext(register struct amigamesa_context *c );
  217. void AmigaMesaMakeCurrent(register struct amigamesa_context *c ,register struct amigamesa_buffer *b);
  218. void AmigaMesaSwapBuffers(register struct amigamesa_context *amesa);
  219. /* This is on the drawingboard */
  220. BOOL AmigaMesaSetDefs(register struct TagItem *tagList);
  221. GLenum AmigaMesaReportError(register struct amigamesa_context *c );
  222. #else
  223. __asm __saveds struct amigamesa_visual *AmigaMesaCreateVisual(register __a0 struct TagItem *tagList);
  224. __asm __saveds struct amigamesa_context *AmigaMesaCreateContext(register __a0 struct TagItem *tagList );
  225. __asm __saveds void AmigaMesaDestroyContext(register __a0 struct amigamesa_context *c );
  226. __asm __saveds void AmigaMesaMakeCurrent(register __a0 struct amigamesa_context *c ,register __a1    struct amigamesa_buffer *b);
  227. __asm __saveds void AmigaMesaSwapBuffers(register __a0 struct amigamesa_context *amesa);
  228. /* This is on the drawingboard */
  229. __asm __saveds BOOL AmigaMesaSetDefs(register __a0 struct TagItem *tagList);
  230. __asm __saveds GLenum AmigaMesaReportError(register __a0 struct amigamesa_context *c );
  231. #endif
  232.  
  233.  
  234.  
  235.  
  236.  
  237. /*
  238.  * Amiga Mesa Attribute tag ID's.  These are used in the ti_Tag field of
  239.  * TagItem arrays passed to AmigaMesaSetDefs() and AmigaMesaCreateContext()
  240.  */
  241. #define AMA_Dummy   (TAG_USER + 32)
  242.  
  243. /*
  244. Offset to use. WARNING AMA_Left, AMA_Bottom Specifies the low left corner
  245. of the drawing area in deltapixles from the lowest left corner
  246. typical AMA_Left,window->BorderLeft
  247.           AMA_Bottom,window->BorderBottom + 1
  248. This is since ALL gl drawing actions is specified with this point as 0,0
  249. and with y positive uppwards (like in real graphs).
  250.  
  251. Untuched (defult) will result in 
  252. AMA_Left=0;
  253. AMA_Bottom=0;
  254. */
  255. #define AMA_Left        (AMA_Dummy + 0x0001)
  256. #define AMA_Bottom  (AMA_Dummy + 0x0002)
  257.  
  258. /*
  259. Size in pixels of drawing area if others than the whole rastport.
  260. All internal drawingbuffers will be in this size
  261.  
  262. Untuched (defult) will result in 
  263. AMA_Width =rp->BitMap->BytesPerRow*8;
  264. AMA_Height=rp->BitMap->Rows;
  265. */
  266. #define AMA_Width   (AMA_Dummy + 0x0003)
  267. #define AMA_Height  (AMA_Dummy + 0x0004)
  268.  
  269. /*
  270. This may become unneaded, and code to autodetect the gfx-card should be added
  271.  
  272.  
  273. AMA_DrawMode: Specifies the drawing hardware and should be one of
  274.                   AGA,(CYBERGFX,RETINA)
  275.                   Defult value: AGA
  276. if AMESA_AGA Amiga native drawigns
  277.     this has to be filled with data
  278.         AMA_Window = (ptr) Window to draw on
  279.     or
  280.         AMA_Screen =(ptr) Screen to draw on.
  281.         AMA_RastPort =(ptr) RastPort to draw on.
  282.  
  283. if AMESA_AGA_C2P Amiga native drawing using a chunky buffer
  284.                  thats converted when switching drawbuffer
  285.                  only works on doublebuffered drawings.
  286.     this has to be filled with data
  287.         AMA_DoubleBuf = GL_TRUE
  288.         AMA_Window = (ptr) Window to draw on
  289.     or
  290.         AMA_DoubleBuf = GL_TRUE
  291.         AMA_Screen =(ptr) Screen to draw on.
  292.         AMA_RastPort =(ptr) RastPort to draw on.
  293.  
  294. else
  295.    here should all needed gfx-card tagitem be specified
  296. */
  297.  
  298. enum DrawModeID {AMESA_AGA,AMESA_AGA_C2P /*,AMESA_CYBERGFX,AMESA_RETINA*/};
  299. #define AMA_DrawMode    (AMA_Dummy + 0x0005)
  300. #define AMA_Screen  (AMA_Dummy + 0x0006)
  301. #define AMA_Window  (AMA_Dummy + 0x0007)
  302. #define AMA_RastPort    (AMA_Dummy + 0x0008)
  303.  
  304. /** booleans **/
  305. /*
  306. AMA_DoubleBuf: If specified it uses double Buffering (change buffer with
  307.                     AmigaMesaSwapBuffers()) Turn this on as much as posible
  308.                     it will result in smother looking and faster rendering
  309.                     Defult value: GL_FALSE
  310. AMA_RGBMode: If specified it uses 24bit when drawing (on non 24bit displays it
  311.                  it emuletes 24bit)
  312.                  Defult value: GL_TRUE
  313. AMA_AlphaFlag: Alphachanel ?
  314.                    Defule value: GL_FALSE
  315. */
  316. #define AMA_DoubleBuf (AMA_Dummy + 0x0030)
  317. #define AMA_RGBMode  (AMA_Dummy + 0x0031)
  318. #define AMA_AlphaFlag (AMA_Dummy + 0x0032)
  319.  
  320.  
  321. /** Special **/
  322. /*
  323. AMA_ShareGLContext: Set the "friend" context (use multiple contexts) 
  324.                           See the GL maual or Mesa to get more info
  325. AMA_Visual: If you want to implement your own amigamesa_visual 
  326. AMA_Buffer: If you want to implement your own amigamesa_buffer
  327. AMA_WindowID: A windowID to use when I alloc AMA_Buffer for you if
  328.                   you didn't supply one.(defult=1)
  329. */
  330.  
  331. #define AMA_ShareGLContext  (AMA_Dummy + 0x0040)
  332. #define AMA_Visual          (AMA_Dummy + 0x0041)
  333. #define AMA_Buffer          (AMA_Dummy + 0x0042)
  334. #define AMA_WindowID            (AMA_Dummy + 0x0043)
  335.  
  336. #ifdef __cplusplus
  337. }
  338. #endif
  339.  
  340.  
  341. #endif
  342.